﻿using Enter.SignalR.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Enter.SignalR.Pages
{
    // https://docs.microsoft.com/zh-cn/aspnet/core/razor-pages/?tabs=visual-studio&view=aspnetcore-5.0
    public class LoginModel : PageModel
    {
        private readonly ILogger<LoginModel> _logger;

        public LoginModel(ILogger<LoginModel> logger)
        {
            _logger = logger;
        }

        public void OnGet()
        {
        }

        [BindProperty]
        public LoginViewModel LoginBind { get; set; }

        public IActionResult OnPost()
        {
            if (LoginBind.Name == "13714852976")
            {
                HttpContext.Session.SetString("User", "新娘");
            }
            else if (LoginBind.Name == "15999568947")
            {
                HttpContext.Session.SetString("User", "新郎");
            }
            return RedirectToPage("./Index");
        }
    }
}
